<template>
  <div>
    <template v-if="nowPlayingFilmList.length === 0">
      <xw-loading />
    </template>
    <template v-else>
      <div class="item" v-for="item in nowPlayingFilmList" :key="item.filmId">
        <div class="left">
          <img :src="item.poster" />
        </div>
        <div class="middle">
          <div>{{ item.name }}</div>
          <div>
            <span>观众评分</span>
            <span>7.6</span>
          </div>
          <div>主演：{{ item.actorsStr }}</div>
          <div>中国大陆 | 150分钟</div>
        </div>
        <div class="right">
          <span>购票</span>
        </div>
      </div>
    </template>
  </div>
</template>

<script>
import { getNowPlayingFilmListApi } from '@/api/filmApi'
export default {
  data() {
    return {
      nowPlayingFilmList: [],
      page: 1
    }
  },
  async mounted() {
    let ret = await getNowPlayingFilmListApi(this.page)
    this.nowPlayingFilmList = ret
  }
}
</script>

<style lang="scss" scoped>
.item {
  margin-top: 15px;
  padding-bottom: 15px;
  display: flex;
  color: #797d82;
  font-size: 13px;
  position: relative;
  /* 用css完成一个移动端1px */
  /* border-bottom: 1px solid #ededed; */
  &::after {
    content: '';
    border-bottom: 1px solid #ccc;
    transform: scale(0.5);
    height: 1px;
    width: 200%;
    position: absolute;
    left: -190px;
    bottom: 0;
  }

  &:last-child {
    margin-bottom: 50px;
    border-bottom: none;
  }
  .left {
    width: 77px;
    height: 100px;
    margin-left: 20px;
    img {
      width: 66px;
      height: 100%;
    }
  }

  .middle {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 55%;

    div:nth-of-type(1) {
      color: #191a1b;
      font-size: 16px;
    }

    /* 文字超过后,隐藏,用... 只对中文,英文无效 */
    div:nth-of-type(3) {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  .right {
    width: 15%;
    display: flex;
    align-items: center;
    margin-right: 20px;

    span {
      border: 1px solid #ff5f16;
      background: white;
      color: #ff5f16;
      border-radius: 2px;
      height: 25px;
      line-height: 25px;
      font-size: 13px;
      width: 50px;
      text-align: center;
    }
  }
}
</style>
